<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="utf-8" />
		<base href="../../../" />
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
	</head>
	<body>
		[page:Loader] &rarr;

		<h1>[name]</h1>

		<p class="desc">用于加载`.svg`资源的加载器<br >
		[link:https://en.wikipedia.org/wiki/Scalable_Vector_Graphics 可伸缩向量图形]是XML形式的矢量图形格式，用来描述二维矢量图形并支持交互和动画。
		</p>

		<h2>引用</h2>

		<p>
			[name]是附加功能，必须显示引用。
			请参考[link:#manual/introduction/Installation Installation / Addons].
		</p>

		<code>
			import { SVGLoader } from 'three/addons/loaders/SVGLoader.js';
		</code>

		<h2>代码示例</h2>

		<code>
		// instantiate a loader
		const loader = new SVGLoader();

		// load a SVG resource
		loader.load(
			// resource URL
			'data/svgSample.svg',
			// called when the resource is loaded
			function ( data ) {

				const paths = data.paths;
				const group = new THREE.Group();

				for ( let i = 0; i < paths.length; i ++ ) {

					const path = paths[ i ];

					const material = new THREE.MeshBasicMaterial( {
						color: path.color,
						side: THREE.DoubleSide,
						depthWrite: false
					} );

					const shapes = SVGLoader.createShapes( path );

					for ( let j = 0; j < shapes.length; j ++ ) {

						const shape = shapes[ j ];
						const geometry = new THREE.ShapeGeometry( shape );
						const mesh = new THREE.Mesh( geometry, material );
						group.add( mesh );

					}

				}

				scene.add( group );

			},
			// called when loading is in progresses
			function ( xhr ) {

				console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

			},
			// called when loading has errors
			function ( error ) {

				console.log( 'An error happened' );

			}
		);
		</code>

		<h2>示例</h2>
		<p>
			[example:webgl_loader_svg]
		</p>

		<h2>构造函数</h2>

		<h3>[name]( [param:LoadingManager manager] )</h3>
		<p>
		[page:LoadingManager manager] — 加载器使用的[page:LoadingManager 加载器管理]。默认值为[page:LoadingManager THREE.DefaultLoadingManager]。
		</p>
		<p>
		创建一个新的[name]。
		</p>

		<h2>属性</h2>
		<p>查看公共属性请参考基类[page:Loader]。</p>

		<h2>方法</h2>
		<p>查看公共方法请参考基类[page:Loader]。</p>

		<h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
		<p>
		[page:String url] — 一个`.svg`文件的路径或者网络地址。<br />
		[page:Function onLoad] — (可选的)加载成功之后调用的函数。该函数以[page:ShapePath]为参数。<br />
		[page:Function onProgress] — (可选的)正在加载时调用的函数。参数为XMLHttpRequest实例，包含[page:Integer total]和[page:Integer loaded]。
		如果服务没有设置Content-Length头，.[page:Integer total]的值为0。<br />
		[page:Function onError] — (可选的)加载出现错误时调用的函数。该函将错误信息作为参数。<br />
		</p>
		<p>
		根据请求的URL开始加载并根据返回内容调用onLoad。
		</p>

		<h2>静态方法</h2>

		<h3>[method:Array createShapes]( [param:ShapePath shape] )</h3>
		<p>
		[page:ShapePath shape] — 一个[page:ShapePath]的矢量图形数组,指定[page:SVGLoader]的onLoad函数的参数。<br />
		</p>
		<p>
			返回一个或多个基于[param:ShapePath shape]的[page:Shape]对象，并作为该函数的一个参数返回。
		</p>

		<h2>源码</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/SVGLoader.js examples/jsm/loaders/SVGLoader.js]
		</p>
	</body>
</html>
